#ifndef BD_H
#define BD_H

typedef struct
{
  void *data;
} BDConnection;

typedef struct
{
  char *name;
  char *value;
} BDPair;

typedef struct
{
  long rows;
  long cols;
  long currRow;
  void *data;
} BDResult;

typedef enum
{
  BD_E_NONE,
  BD_E_ERROR,
  BD_E_NOT_SUPPORTED
} BDError;

typedef enum
{
  BD_C_OK,
  BD_C_NOT_OK,
  BD_C_NOT_DEFINED
} BDConnectionStatus;

typedef enum
{
  BD_T_OK,
  BD_T_IDLE,
  BD_T_ERR,
  BD_T_NOT_DEFINED
} BDTransactionStatus;



/*
TRANSACTIONS:

MYSQL: http://dev.mysql.com/tech-resources/articles/mysql-connector-cpp.html#trx
----------
1- autocommit false

   mysql_autocommit(conn, 0); 
   //Do stuff here
   mysql_commit(conn); //...or mysql_rollback(conn);

2- query
   I would rather use the "query" method for all these calls:

   mysql_query(conn, "START TRANSACTION");
   //Do stuff here
   mysql_query(conn, "COMMIT"); //...or mysql_query(conn, "ROLLBACK"); 

*/

BDConnection *bdConnect(BDPair *params);
void bdDisconnect(BDConnection *connection);
BDConnectionStatus bdConnectionStatus(BDConnection *conn);

BDError bdBeginTransaction(BDConnection *conn);
BDError bdCommitTransaction(BDConnection *conn);
BDError bdRollbackTransaction(BDConnection *conn);
BDTransactionStatus bdTransactionStatus(BDConnection *conn);

//insert,delete,update
BDError bdExecCommand(BDConnection *conn, char *query, char *values[], int numParams);
//select
BDResult *bdExecQuery(BDConnection *conn, char *query, char *values[], int numParams);

char *bdResultColName(BDResult *result, long num);

int bdNextRow(BDResult *result);
char *bdResultVal(BDResult *result, long col);

void bdFreeResult(BDResult *result);

char *bdType();

#endif
